#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/11/26 15:02
# @Author  : 新猿异码
# @Site    : https://gitee.com/chshao/autotest
# @CSDN    : https://blog.csdn.net/m0_37576542?type=blog
# @File    : ConfReader.py
# @Desc    : 加载配置文件
# @Software: PyCharm
import os
import yaml


class ConfReader(object):

    @staticmethod
    def read(yaml_file):
        if not os.path.exists(yaml_file):
            raise FileNotFoundError(yaml_file)
        fs = open(yaml_file, 'r', encoding="utf-8")
        conf_content = fs.read()
        fs.close()

        return yaml.safe_load(conf_content)


if __name__ == '__main__':
    print(ConfReader.read(r"D:\workspace\AutoTest-Python\autotest\resource\config.yaml"))

